home *** CD-ROM | disk | FTP | other *** search
- package com.sun.java.swing;
-
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.Point;
- import java.awt.Rectangle;
- import java.awt.Shape;
- import java.awt.Toolkit;
- import java.awt.Window;
- import java.awt.image.FilteredImageSource;
- import java.awt.image.ImageObserver;
- import java.awt.image.ImageProducer;
- import java.io.PrintStream;
-
- public class DebugGraphics extends Graphics {
- Graphics graphics;
- Image buffer;
- int debugOptions;
- int graphicsID;
- int xOffset;
- int yOffset;
- private static int graphicsCount = 0;
- public static final int LOG_OPTION = 1;
- public static final int FLASH_OPTION = 2;
- public static final int BUFFERED_OPTION = 4;
- public static final int NONE_OPTION = -1;
- private static final Class debugGraphicsInfoKey;
- static Class class$com$sun$java$swing$DebugGraphicsInfo;
-
- static {
- Class var10000 = class$com$sun$java$swing$DebugGraphicsInfo;
- if (var10000 == null) {
- try {
- var10000 = Class.forName("com.sun.java.swing.DebugGraphicsInfo");
- } catch (ClassNotFoundException var0) {
- throw new NoClassDefFoundError(((Throwable)var0).getMessage());
- }
-
- class$com$sun$java$swing$DebugGraphicsInfo = var10000;
- }
-
- debugGraphicsInfoKey = var10000;
- }
-
- public DebugGraphics() {
- this.graphicsID = graphicsCount++;
- this.buffer = null;
- this.xOffset = this.yOffset = 0;
- }
-
- public DebugGraphics(Graphics graphics) {
- this();
- this.graphics = graphics;
- }
-
- public DebugGraphics(Graphics graphics, JComponent component) {
- this(graphics);
- this.setDebugOptions(component.shouldDebugGraphics());
- }
-
- public void clearRect(int x, int y, int width, int height) {
- DebugGraphicsInfo info = info();
- if (this.debugLog()) {
- info().log(this.toShortString() + " Clearing rect: " + new Rectangle(x, y, width, height));
- }
-
- if (this.isDrawingBuffer()) {
- if (this.debugBuffered()) {
- Graphics debugGraphics = this.debugGraphics();
- debugGraphics.clearRect(x, y, width, height);
- debugGraphics.dispose();
- }
- } else if (this.debugFlash()) {
- Color oldColor = this.getColor();
- int count = info.flashCount * 2 - 1;
-
- for(int i = 0; i < count; ++i) {
- this.graphics.setColor(i % 2 == 0 ? info.flashColor : oldColor);
- this.graphics.clearRect(x, y, width, height);
- Toolkit.getDefaultToolkit().sync();
- this.sleep(info.flashTime);
- }
-
- this.graphics.setColor(oldColor);
- }
-
- this.graphics.clearRect(x, y, width, height);
- }
-
- public void clipRect(int x, int y, int width, int height) {
- this.graphics.clipRect(x, y, width, height);
- if (this.debugLog()) {
- info().log(this.toShortString() + " Setting clipRect: " + new Rectangle(x, y, width, height) + " New clipRect: " + this.graphics.getClip());
- }
-
- }
-
- public void copyArea(int x, int y, int width, int height, int destX, int destY) {
- if (this.debugLog()) {
- info().log(this.toShortString() + " Copying area from: " + new Rectangle(x, y, width, height) + " to: " + new Point(destX, destY));
- }
-
- this.graphics.copyArea(x, y, width, height, destX, destY);
- }
-
- public Graphics create() {
- DebugGraphics debugGraphics = new DebugGraphics();
- debugGraphics.graphics = this.graphics.create();
- debugGraphics.debugOptions = this.debugOptions;
- debugGraphics.buffer = this.buffer;
- return debugGraphics;
- }
-
- public Graphics create(int x, int y, int width, int height) {
- DebugGraphics debugGraphics = new DebugGraphics();
- debugGraphics.graphics = SwingGraphics.createGraphics(this.graphics, x, y, width, height);
- debugGraphics.debugOptions = this.debugOptions;
- debugGraphics.buffer = this.buffer;
- debugGraphics.xOffset = this.xOffset + x;
- debugGraphics.yOffset = this.yOffset + y;
- return debugGraphics;
- }
-
- boolean debugBuffered() {
- return (this.debugOptions & 4) == 4;
- }
-
- static int debugComponentCount() {
- DebugGraphicsInfo debugGraphicsInfo = info();
- return debugGraphicsInfo != null && debugGraphicsInfo.componentToDebug != null ? debugGraphicsInfo.componentToDebug.size() : 0;
- }
-
- boolean debugFlash() {
- return (this.debugOptions & 2) == 2;
- }
-
- private Graphics debugGraphics() {
- DebugGraphicsInfo info = info();
- if (info.debugFrame == null) {
- info.debugFrame = new JFrame();
- info.debugFrame.setSize(500, 500);
- }
-
- JFrame debugFrame = info.debugFrame;
- ((Window)debugFrame).show();
- DebugGraphics debugGraphics = new DebugGraphics(((Component)debugFrame).getGraphics());
- debugGraphics.setFont(this.getFont());
- debugGraphics.setColor(this.getColor());
- debugGraphics.translate(this.xOffset, this.yOffset);
- debugGraphics.setClip(this.getClipBounds());
- if (this.debugFlash()) {
- debugGraphics.setDebugOptions(2);
- }
-
- return debugGraphics;
- }
-
- boolean debugLog() {
- return (this.debugOptions & 1) == 1;
- }
-
- public void dispose() {
- this.graphics.dispose();
- this.graphics = null;
- }
-
- public void draw3DRect(int x, int y, int width, int height, boolean raised) {
- DebugGraphicsInfo info = info();
- if (this.debugLog()) {
- info().log(this.toShortString() + " Drawing 3D rect: " + new Rectangle(x, y, width, height) + " Raised bezel: " + raised);
- }
-
- if (this.isDrawingBuffer()) {
- if (this.debugBuffered()) {
- Graphics debugGraphics = this.debugGraphics();
- debugGraphics.draw3DRect(x, y, width, height, raised);
- debugGraphics.dispose();
- }
- } else if (this.debugFlash()) {
- Color oldColor = this.getColor();
- int count = info.flashCount * 2 - 1;
-
- for(int i = 0; i < count; ++i) {
- this.graphics.setColor(i % 2 == 0 ? info.flashColor : oldColor);
- this.graphics.draw3DRect(x, y, width, height, raised);
- Toolkit.getDefaultToolkit().sync();
- this.sleep(info.flashTime);
- }
-
- this.graphics.setColor(oldColor);
- }
-
- this.graphics.draw3DRect(x, y, width, height, raised);
- }
-
- public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
- DebugGraphicsInfo info = info();
- if (this.debugLog()) {
- info().log(this.toShortString() + " Drawing arc: " + new Rectangle(x, y, width, height) + " startAngle: " + startAngle + " arcAngle: " + arcAngle);
- }
-
- if (this.isDrawingBuffer()) {
- if (this.debugBuffered()) {
- Graphics debugGraphics = this.debugGraphics();
- debugGraphics.drawArc(x, y, width, height, startAngle, arcAngle);
- debugGraphics.dispose();
- }
- } else if (this.debugFlash()) {
- Color oldColor = this.getColor();
- int count = info.flashCount * 2 - 1;
-
- for(int i = 0; i < count; ++i) {
- this.graphics.setColor(i % 2 == 0 ? info.flashColor : oldColor);
- this.graphics.drawArc(x, y, width, height, startAngle, arcAngle);
- Toolkit.getDefaultToolkit().sync();
- this.sleep(info.flashTime);
- }
-
- this.graphics.setColor(oldColor);
- }
-
- this.graphics.drawArc(x, y, width, height, startAngle, arcAngle);
- }
-
- public void drawBytes(byte[] data, int offset, int length, int x, int y) {
- DebugGraphicsInfo info = info();
- this.graphics.getFont();
- if (this.debugLog()) {
- info().log(this.toShortString() + " Drawing bytes at: " + new Point(x, y));
- }
-
- if (this.isDrawingBuffer()) {
- if (this.debugBuffered()) {
- Graphics debugGraphics = this.debugGraphics();
- debugGraphics.drawBytes(data, offset, length, x, y);
- debugGraphics.dispose();
- }
- } else if (this.debugFlash()) {
- Color oldColor = this.getColor();
- int count = info.flashCount * 2 - 1;
-
- for(int i = 0; i < count; ++i) {
- this.graphics.setColor(i % 2 == 0 ? info.flashColor : oldColor);
- this.graphics.drawBytes(data, offset, length, x, y);
- Toolkit.getDefaultToolkit().sync();
- this.sleep(info.flashTime);
- }
-
- this.graphics.setColor(oldColor);
- }
-
- this.graphics.drawBytes(data, offset, length, x, y);
- }
-
- public void drawChars(char[] data, int offset, int length, int x, int y) {
- DebugGraphicsInfo info = info();
- this.graphics.getFont();
- if (this.debugLog()) {
- info().log(this.toShortString() + " Drawing chars at " + new Point(x, y));
- }
-
- if (this.isDrawingBuffer()) {
- if (this.debugBuffered()) {
- Graphics debugGraphics = this.debugGraphics();
- debugGraphics.drawChars(data, offset, length, x, y);
- debugGraphics.dispose();
- }
- } else if (this.debugFlash()) {
- Color oldColor = this.getColor();
- int count = info.flashCount * 2 - 1;
-
- for(int i = 0; i < count; ++i) {
- this.graphics.setColor(i % 2 == 0 ? info.flashColor : oldColor);
- this.graphics.drawChars(data, offset, length, x, y);
- Toolkit.getDefaultToolkit().sync();
- this.sleep(info.flashTime);
- }
-
- this.graphics.setColor(oldColor);
- }
-
- this.graphics.drawChars(data, offset, length, x, y);
- }
-
- public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) {
- return this.graphics.drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, bgcolor, observer);
- }
-
- public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) {
- return this.graphics.drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, observer);
- }
-
- public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) {
- return this.graphics.drawImage(img, x, y, width, height, bgcolor, observer);
- }
-
- public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer) {
- return this.graphics.drawImage(img, x, y, width, height, observer);
- }
-
- public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer) {
- return this.graphics.drawImage(img, x, y, bgcolor, observer);
- }
-
- public boolean drawImage(Image img, int x, int y, ImageObserver observer) {
- DebugGraphicsInfo info = info();
- if (this.debugLog()) {
- info().log(this.toShortString() + " Drawing image: " + img + " at: " + new Point(x, y));
- }
-
- if (this.isDrawingBuffer()) {
- if (this.debugBuffered()) {
- Graphics debugGraphics = this.debugGraphics();
- debugGraphics.drawImage(img, x, y, observer);
- debugGraphics.dispose();
- }
- } else if (this.debugFlash()) {
- int count = info.flashCount * 2 - 1;
- ImageProducer oldProducer = img.getSource();
- ImageProducer newProducer = new FilteredImageSource(oldProducer, new DebugGraphicsFilter(info.flashColor));
- Image newImage = Toolkit.getDefaultToolkit().createImage(newProducer);
- DebugGraphicsObserver imageObserver = new DebugGraphicsObserver();
-
- for(int i = 0; i < count; ++i) {
- this.graphics.drawImage(i % 2 == 0 ? newImage : img, x, y, imageObserver);
- Toolkit.getDefaultToolkit().sync();
-
- while(!imageObserver.allBitsPresent() && !imageObserver.imageHasProblem()) {
- this.sleep(10);
- }
-
- this.sleep(info.flashTime);
- }
- }
-
- return this.graphics.drawImage(img, x, y, observer);
- }
-
- public void drawLine(int x1, int y1, int x2, int y2) {
- DebugGraphicsInfo info = info();
- if (this.debugLog()) {
- info().log(this.toShortString() + " Drawing line: from " + this.pointToString(x1, y1) + " to " + this.pointToString(x2, y2));
- }
-
- if (this.isDrawingBuffer()) {
- if (this.debugBuffered()) {
- Graphics debugGraphics = this.debugGraphics();
- debugGraphics.drawLine(x1, y1, x2, y2);
- debugGraphics.dispose();
- }
- } else if (this.debugFlash()) {
- Color oldColor = this.getColor();
- int count = info.flashCount * 2 - 1;
-
- for(int i = 0; i < count; ++i) {
- this.graphics.setColor(i % 2 == 0 ? info.flashColor : oldColor);
- this.graphics.drawLine(x1, y1, x2, y2);
- Toolkit.getDefaultToolkit().sync();
- this.sleep(info.flashTime);
- }
-
- this.graphics.setColor(oldColor);
- }
-
- this.graphics.drawLine(x1, y1, x2, y2);
- }
-
- public void drawOval(int x, int y, int width, int height) {
- DebugGraphicsInfo info = info();
- if (this.debugLog()) {
- info().log(this.toShortString() + " Drawing oval: " + new Rectangle(x, y, width, height));
- }
-
- if (this.isDrawingBuffer()) {
- if (this.debugBuffered()) {
- Graphics debugGraphics = this.debugGraphics();
- debugGraphics.drawOval(x, y, width, height);
- debugGraphics.dispose();
- }
- } else if (this.debugFlash()) {
- Color oldColor = this.getColor();
- int count = info.flashCount * 2 - 1;
-
- for(int i = 0; i < count; ++i) {
- this.graphics.setColor(i % 2 == 0 ? info.flashColor : oldColor);
- this.graphics.drawOval(x, y, width, height);
- Toolkit.getDefaultToolkit().sync();
- this.sleep(info.flashTime);
- }
-
- this.graphics.setColor(oldColor);
- }
-
- this.graphics.drawOval(x, y, width, height);
- }
-
- public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) {
- DebugGraphicsInfo info = info();
- if (this.debugLog()) {
- info().log(this.toShortString() + " Drawing polygon: " + " nPoints: " + nPoints + " X's: " + xPoints + " Y's: " + yPoints);
- }
-
- if (this.isDrawingBuffer()) {
- if (this.debugBuffered()) {
- Graphics debugGraphics = this.debugGraphics();
- debugGraphics.drawPolygon(xPoints, yPoints, nPoints);
- debugGraphics.dispose();
- }
- } else if (this.debugFlash()) {
- Color oldColor = this.getColor();
- int count = info.flashCount * 2 - 1;
-
- for(int i = 0; i < count; ++i) {
- this.graphics.setColor(i % 2 == 0 ? info.flashColor : oldColor);
- this.graphics.drawPolygon(xPoints, yPoints, nPoints);
- Toolkit.getDefaultToolkit().sync();
- this.sleep(info.flashTime);
- }
-
- this.graphics.setColor(oldColor);
- }
-
- this.graphics.drawPolygon(xPoints, yPoints, nPoints);
- }
-
- public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints) {
- DebugGraphicsInfo info = info();
- if (this.debugLog()) {
- info().log(this.toShortString() + " Drawing polyline: " + " nPoints: " + nPoints + " X's: " + xPoints + " Y's: " + yPoints);
- }
-
- if (this.isDrawingBuffer()) {
- if (this.debugBuffered()) {
- Graphics debugGraphics = this.debugGraphics();
- debugGraphics.drawPolyline(xPoints, yPoints, nPoints);
- debugGraphics.dispose();
- }
- } else if (this.debugFlash()) {
- Color oldColor = this.getColor();
- int count = info.flashCount * 2 - 1;
-
- for(int i = 0; i < count; ++i) {
- this.graphics.setColor(i % 2 == 0 ? info.flashColor : oldColor);
- this.graphics.drawPolyline(xPoints, yPoints, nPoints);
- Toolkit.getDefaultToolkit().sync();
- this.sleep(info.flashTime);
- }
-
- this.graphics.setColor(oldColor);
- }
-
- this.graphics.drawPolyline(xPoints, yPoints, nPoints);
- }
-
- public void drawRect(int x, int y, int width, int height) {
- DebugGraphicsInfo info = info();
- if (this.debugLog()) {
- info().log(this.toShortString() + " Drawing rect: " + new Rectangle(x, y, width, height));
- }
-
- if (this.isDrawingBuffer()) {
- if (this.debugBuffered()) {
- Graphics debugGraphics = this.debugGraphics();
- debugGraphics.drawRect(x, y, width, height);
- debugGraphics.dispose();
- }
- } else if (this.debugFlash()) {
- Color oldColor = this.getColor();
- int count = info.flashCount * 2 - 1;
-
- for(int i = 0; i < count; ++i) {
- this.graphics.setColor(i % 2 == 0 ? info.flashColor : oldColor);
- this.graphics.drawRect(x, y, width, height);
- Toolkit.getDefaultToolkit().sync();
- this.sleep(info.flashTime);
- }
-
- this.graphics.setColor(oldColor);
- }
-
- this.graphics.drawRect(x, y, width, height);
- }
-
- public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) {
- DebugGraphicsInfo info = info();
- if (this.debugLog()) {
- info().log(this.toShortString() + " Drawing round rect: " + new Rectangle(x, y, width, height) + " arcWidth: " + arcWidth + " archHeight: " + arcHeight);
- }
-
- if (this.isDrawingBuffer()) {
- if (this.debugBuffered()) {
- Graphics debugGraphics = this.debugGraphics();
- debugGraphics.drawRoundRect(x, y, width, height, arcWidth, arcHeight);
- debugGraphics.dispose();
- }
- } else if (this.debugFlash()) {
- Color oldColor = this.getColor();
- int count = info.flashCount * 2 - 1;
-
- for(int i = 0; i < count; ++i) {
- this.graphics.setColor(i % 2 == 0 ? info.flashColor : oldColor);
- this.graphics.drawRoundRect(x, y, width, height, arcWidth, arcHeight);
- Toolkit.getDefaultToolkit().sync();
- this.sleep(info.flashTime);
- }
-
- this.graphics.setColor(oldColor);
- }
-
- this.graphics.drawRoundRect(x, y, width, height, arcWidth, arcHeight);
- }
-
- public void drawString(String aString, int x, int y) {
- DebugGraphicsInfo info = info();
- if (this.debugLog()) {
- info().log(this.toShortString() + " Drawing string: \"" + aString + "\" at: " + new Point(x, y));
- }
-
- if (this.isDrawingBuffer()) {
- if (this.debugBuffered()) {
- Graphics debugGraphics = this.debugGraphics();
- debugGraphics.drawString(aString, x, y);
- debugGraphics.dispose();
- }
- } else if (this.debugFlash()) {
- Color oldColor = this.getColor();
- int count = info.flashCount * 2 - 1;
-
- for(int i = 0; i < count; ++i) {
- this.graphics.setColor(i % 2 == 0 ? info.flashColor : oldColor);
- this.graphics.drawString(aString, x, y);
- Toolkit.getDefaultToolkit().sync();
- this.sleep(info.flashTime);
- }
-
- this.graphics.setColor(oldColor);
- }
-
- this.graphics.drawString(aString, x, y);
- }
-
- public void fill3DRect(int x, int y, int width, int height, boolean raised) {
- DebugGraphicsInfo info = info();
- if (this.debugLog()) {
- info().log(this.toShortString() + " Filling 3D rect: " + new Rectangle(x, y, width, height) + " Raised bezel: " + raised);
- }
-
- if (this.isDrawingBuffer()) {
- if (this.debugBuffered()) {
- Graphics debugGraphics = this.debugGraphics();
- debugGraphics.fill3DRect(x, y, width, height, raised);
- debugGraphics.dispose();
- }
- } else if (this.debugFlash()) {
- Color oldColor = this.getColor();
- int count = info.flashCount * 2 - 1;
-
- for(int i = 0; i < count; ++i) {
- this.graphics.setColor(i % 2 == 0 ? info.flashColor : oldColor);
- this.graphics.fill3DRect(x, y, width, height, raised);
- Toolkit.getDefaultToolkit().sync();
- this.sleep(info.flashTime);
- }
-
- this.graphics.setColor(oldColor);
- }
-
- this.graphics.fill3DRect(x, y, width, height, raised);
- }
-
- public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
- DebugGraphicsInfo info = info();
- if (this.debugLog()) {
- info().log(this.toShortString() + " Filling arc: " + new Rectangle(x, y, width, height) + " startAngle: " + startAngle + " arcAngle: " + arcAngle);
- }
-
- if (this.isDrawingBuffer()) {
- if (this.debugBuffered()) {
- Graphics debugGraphics = this.debugGraphics();
- debugGraphics.fillArc(x, y, width, height, startAngle, arcAngle);
- debugGraphics.dispose();
- }
- } else if (this.debugFlash()) {
- Color oldColor = this.getColor();
- int count = info.flashCount * 2 - 1;
-
- for(int i = 0; i < count; ++i) {
- this.graphics.setColor(i % 2 == 0 ? info.flashColor : oldColor);
- this.graphics.fillArc(x, y, width, height, startAngle, arcAngle);
- Toolkit.getDefaultToolkit().sync();
- this.sleep(info.flashTime);
- }
-
- this.graphics.setColor(oldColor);
- }
-
- this.graphics.fillArc(x, y, width, height, startAngle, arcAngle);
- }
-
- public void fillOval(int x, int y, int width, int height) {
- DebugGraphicsInfo info = info();
- if (this.debugLog()) {
- info().log(this.toShortString() + " Filling oval: " + new Rectangle(x, y, width, height));
- }
-
- if (this.isDrawingBuffer()) {
- if (this.debugBuffered()) {
- Graphics debugGraphics = this.debugGraphics();
- debugGraphics.fillOval(x, y, width, height);
- debugGraphics.dispose();
- }
- } else if (this.debugFlash()) {
- Color oldColor = this.getColor();
- int count = info.flashCount * 2 - 1;
-
- for(int i = 0; i < count; ++i) {
- this.graphics.setColor(i % 2 == 0 ? info.flashColor : oldColor);
- this.graphics.fillOval(x, y, width, height);
- Toolkit.getDefaultToolkit().sync();
- this.sleep(info.flashTime);
- }
-
- this.graphics.setColor(oldColor);
- }
-
- this.graphics.fillOval(x, y, width, height);
- }
-
- public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) {
- DebugGraphicsInfo info = info();
- if (this.debugLog()) {
- info().log(this.toShortString() + " Filling polygon: " + " nPoints: " + nPoints + " X's: " + xPoints + " Y's: " + yPoints);
- }
-
- if (this.isDrawingBuffer()) {
- if (this.debugBuffered()) {
- Graphics debugGraphics = this.debugGraphics();
- debugGraphics.fillPolygon(xPoints, yPoints, nPoints);
- debugGraphics.dispose();
- }
- } else if (this.debugFlash()) {
- Color oldColor = this.getColor();
- int count = info.flashCount * 2 - 1;
-
- for(int i = 0; i < count; ++i) {
- this.graphics.setColor(i % 2 == 0 ? info.flashColor : oldColor);
- this.graphics.fillPolygon(xPoints, yPoints, nPoints);
- Toolkit.getDefaultToolkit().sync();
- this.sleep(info.flashTime);
- }
-
- this.graphics.setColor(oldColor);
- }
-
- this.graphics.fillPolygon(xPoints, yPoints, nPoints);
- }
-
- public void fillRect(int x, int y, int width, int height) {
- DebugGraphicsInfo info = info();
- if (this.debugLog()) {
- info().log(this.toShortString() + " Filling rect: " + new Rectangle(x, y, width, height));
- }
-
- if (this.isDrawingBuffer()) {
- if (this.debugBuffered()) {
- Graphics debugGraphics = this.debugGraphics();
- debugGraphics.fillRect(x, y, width, height);
- debugGraphics.dispose();
- }
- } else if (this.debugFlash()) {
- Color oldColor = this.getColor();
- int count = info.flashCount * 2 - 1;
-
- for(int i = 0; i < count; ++i) {
- this.graphics.setColor(i % 2 == 0 ? info.flashColor : oldColor);
- this.graphics.fillRect(x, y, width, height);
- Toolkit.getDefaultToolkit().sync();
- this.sleep(info.flashTime);
- }
-
- this.graphics.setColor(oldColor);
- }
-
- this.graphics.fillRect(x, y, width, height);
- }
-
- public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) {
- DebugGraphicsInfo info = info();
- if (this.debugLog()) {
- info().log(this.toShortString() + " Filling round rect: " + new Rectangle(x, y, width, height) + " arcWidth: " + arcWidth + " archHeight: " + arcHeight);
- }
-
- if (this.isDrawingBuffer()) {
- if (this.debugBuffered()) {
- Graphics debugGraphics = this.debugGraphics();
- debugGraphics.fillRoundRect(x, y, width, height, arcWidth, arcHeight);
- debugGraphics.dispose();
- }
- } else if (this.debugFlash()) {
- Color oldColor = this.getColor();
- int count = info.flashCount * 2 - 1;
-
- for(int i = 0; i < count; ++i) {
- this.graphics.setColor(i % 2 == 0 ? info.flashColor : oldColor);
- this.graphics.fillRoundRect(x, y, width, height, arcWidth, arcHeight);
- Toolkit.getDefaultToolkit().sync();
- this.sleep(info.flashTime);
- }
-
- this.graphics.setColor(oldColor);
- }
-
- this.graphics.fillRoundRect(x, y, width, height, arcWidth, arcHeight);
- }
-
- public static Color flashColor() {
- return info().flashColor;
- }
-
- public static int flashCount() {
- return info().flashCount;
- }
-
- public static int flashTime() {
- return info().flashTime;
- }
-
- public Shape getClip() {
- return this.graphics.getClip();
- }
-
- public Rectangle getClipBounds() {
- return this.graphics.getClipBounds();
- }
-
- public Color getColor() {
- return this.graphics.getColor();
- }
-
- public int getDebugOptions() {
- return this.debugOptions;
- }
-
- static int getDebugOptions(JComponent component) {
- DebugGraphicsInfo debugGraphicsInfo = info();
- return debugGraphicsInfo == null ? 0 : debugGraphicsInfo.getDebugOptions(component);
- }
-
- public Font getFont() {
- return this.graphics.getFont();
- }
-
- public FontMetrics getFontMetrics() {
- return this.graphics.getFontMetrics();
- }
-
- public FontMetrics getFontMetrics(Font f) {
- return this.graphics.getFontMetrics(f);
- }
-
- static DebugGraphicsInfo info() {
- DebugGraphicsInfo debugGraphicsInfo = (DebugGraphicsInfo)SwingUtilities.appContextGet(debugGraphicsInfoKey);
- if (debugGraphicsInfo == null) {
- debugGraphicsInfo = new DebugGraphicsInfo();
- SwingUtilities.appContextPut(debugGraphicsInfoKey, debugGraphicsInfo);
- }
-
- return debugGraphicsInfo;
- }
-
- public boolean isDrawingBuffer() {
- return this.buffer != null;
- }
-
- public static PrintStream logStream() {
- return info().stream;
- }
-
- String pointToString(int x, int y) {
- StringBuffer buffer = new StringBuffer("(" + x + ", " + y + ")");
- return buffer.toString();
- }
-
- public void setClip(int x, int y, int width, int height) {
- this.graphics.setClip(x, y, width, height);
- if (this.debugLog()) {
- info().log(this.toShortString() + " Setting new clipRect: " + this.graphics.getClip());
- }
-
- }
-
- public void setClip(Shape clip) {
- this.graphics.setClip(clip);
- if (this.debugLog()) {
- info().log(this.toShortString() + " Setting new clipRect: " + this.graphics.getClip());
- }
-
- }
-
- public void setColor(Color aColor) {
- if (this.debugLog()) {
- info().log(this.toShortString() + " Setting color: " + aColor);
- }
-
- this.graphics.setColor(aColor);
- }
-
- public void setDebugOptions(int options) {
- if (options != 0) {
- if (options == -1) {
- if (this.debugOptions != 0) {
- System.err.println(this.toShortString() + " Disabling debug");
- this.debugOptions = 0;
- }
- } else if (this.debugOptions != options) {
- this.debugOptions |= options;
- if (this.debugLog()) {
- System.err.println(this.toShortString() + " Enabling debug");
- }
- }
- }
-
- }
-
- static void setDebugOptions(JComponent component, int options) {
- info().setDebugOptions(component, options);
- }
-
- public static void setFlashColor(Color flashColor) {
- info().flashColor = flashColor;
- }
-
- public static void setFlashCount(int flashCount) {
- info().flashCount = flashCount;
- }
-
- public static void setFlashTime(int flashTime) {
- info().flashTime = flashTime;
- }
-
- public void setFont(Font aFont) {
- if (this.debugLog()) {
- info().log(this.toShortString() + " Setting font: " + aFont);
- }
-
- this.graphics.setFont(aFont);
- }
-
- public static void setLogStream(PrintStream stream) {
- info().stream = stream;
- }
-
- public void setPaintMode() {
- if (this.debugLog()) {
- info().log(this.toShortString() + " Setting paint mode");
- }
-
- this.graphics.setPaintMode();
- }
-
- public void setXORMode(Color aColor) {
- if (this.debugLog()) {
- info().log(this.toShortString() + " Setting XOR mode: " + aColor);
- }
-
- this.graphics.setXORMode(aColor);
- }
-
- static int shouldComponentDebug(JComponent component) {
- DebugGraphicsInfo info = info();
- if (info == null) {
- return 0;
- } else {
- Container container = component;
-
- int debugOptions;
- for(debugOptions = 0; container != null && container instanceof JComponent; container = ((Component)container).getParent()) {
- debugOptions |= info.getDebugOptions((JComponent)container);
- }
-
- return debugOptions;
- }
- }
-
- final void sleep(int mSecs) {
- try {
- Thread.sleep((long)mSecs);
- } catch (Exception var2) {
- }
-
- }
-
- String toShortString() {
- StringBuffer buffer = new StringBuffer("Graphics" + (this.isDrawingBuffer() ? "<B>" : "") + "(" + this.graphicsID + "-" + this.debugOptions + ")");
- return buffer.toString();
- }
-
- public void translate(int x, int y) {
- if (this.debugLog()) {
- info().log(this.toShortString() + " Translating by: " + new Point(x, y));
- }
-
- this.xOffset += x;
- this.yOffset += y;
- this.graphics.translate(x, y);
- }
- }
-